package com.copm.demonstrationsystem.controller.introductionfeatures;

import com.copm.demonstrationsystem.commons.response.ResponseStatus;
import com.copm.demonstrationsystem.commons.util.ControllerUtils;
import com.copm.demonstrationsystem.service.introductionfeatures.BootPageService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author: Yuan Baiyu
 * @Date: Created in 11:12 2018/5/1
 */
@RestController
@RequestMapping("/bootpage")
@CrossOrigin
public class BootPageController {

    @Autowired
    BootPageService bootPageService;

    //获取“引导”页面的全部信息
    @ApiOperation("启动页面的信息获取接口")
    @GetMapping
    ResponseStatus getPage() {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                bootPageService.getPage());
    }

    //修改“引导”页面的标签文本
    @ApiOperation("启动页面的文本修改接口")
//    @ApiImplicitParam(name = "host", value = "开发商"
//            , dataType = "String", paramType = "query", required = true)
    @PostMapping("/text")
    ResponseStatus modifyBootPageText(@RequestParam("host") String host,
                                      @RequestParam("address") String address,
                                      @RequestParam("hotline") String hotline) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                bootPageService.modifyBootPageText(host, address, hotline));
    }

    //修改“引导”页面的背景图片
    @ApiOperation("启动页面的图片修改接口")
    @ApiImplicitParam(name = "file", value = "新“引导”页面的背景图片"
            , dataType = "file", paramType = "form", required = true)
    @PostMapping("/image")
    ResponseStatus modifyBootPageImage(@RequestPart("file") MultipartFile file) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                bootPageService.modifyBootPageImage(file));
    }

    //修改logo
    @ApiOperation("启动页面的logo修改接口")
    @PostMapping("/logo")
    ResponseStatus modifyBootPageLogo(@RequestPart("file") MultipartFile file) {
        return ControllerUtils.fillResponse(new ResponseStatus(),
                bootPageService.modifyBootPageLogo(file));
    }


//---------------------------------------------------------------------------------------------------------- ----------

    //    //添加“引导”页面的背景图片
////    @ApiOperation("启动页面的图片添加接口")
////    @ApiImplicitParam(name = "file",value = "“引导”页面的背景图片"
////            ,dataType = "MultipartFile",paramType = "form",required = true)
////    @PostMapping("/image")
////    ResponseStatus addBootPageImage(@RequestPart("file") MultipartFile file) {
////        return ControllerUtils.fillResponse(new ResponseStatus(),
////                bootPageService.addBootPageImage(file));
////    }

//    //删除“引导”页面的背景图片
//    @DeleteMapping("/image")
//    @ApiOperation("启动页面的图片删除接口")
//    ResponseStatus deleteBootPageImage() {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                bootPageService.deleteBootPageImage());
//    }


    //    //添加“引导”页面的标签文本
//    @ApiOperation("启动页面的文本添加接口")
//    @ApiImplicitParam(name = "title", value = "“引导”页面的标签文本内容"
//            , dataType = "String", paramType = "query", required = true)
//    @PostMapping("/text")
//    ResponseStatus addBootPageText(@RequestParam("title") String title) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                bootPageService.addBootPageText(title));
//    }

//
//    //删除“引导”页面的标签文本
//    @ApiOperation("启动页面的文本删除接口")
//    @ApiImplicitParam(name = "id", value = "“引导”页面的标签文本标识ID"
//            , dataType = "Long", paramType = "path", required = true)
//    @DeleteMapping("/text/{id}")
//    ResponseStatus deleteBootPageText(@PathVariable("id") Long id) {
//        return ControllerUtils.fillResponse(new ResponseStatus(),
//                bootPageService.deleteBootPageText(id));
//    }
}